home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / VGAMODE.ZIP / MODE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-14  |  1.1 KB  |  72 lines

  1. #include <asm/io.h>
  2.  
  3. #include "vga.h"
  4.  
  5. int vga_mode_get(struct vgamode_t *themode)
  6. {
  7.     int i;
  8.  
  9.     themode->MiscOutReg = inb(0x3CC);
  10.  
  11.     inb(0x3DA);
  12.     outb(0x00, 0x3C0);
  13.  
  14.     for (i=0; i<25; i++) {
  15.         outb(i, 0x3D4); 
  16.         themode->CRTC[i] = inb(0x3D5);
  17.     }
  18.  
  19.     for (i=0; i<21; i++) {
  20.         inb(0x3DA);
  21.         outb(i, 0x3C0);
  22.         themode->Attribute[i] = inb(0x3C1);
  23.     }
  24.  
  25.     for (i=0; i<9; i++) {
  26.         outb(i, 0x3CE);
  27.         themode->Graphics[i] = inb(0x3CF);
  28.     }
  29.  
  30.     for (i=0; i<5; i++) {
  31.         outb(i, 0x3C4);
  32.         themode->Sequencer[i] = inb(0x3C5);
  33.     }
  34.  
  35.     inb(0x3DA);
  36.     outb(0x20, 0x3C0);
  37.  
  38.     return VGA_OK;
  39. }
  40.  
  41. int vga_mode_set(struct vgamode_t *themode)
  42. {
  43.     int i;
  44.  
  45.     inb(0x3DA);
  46.     outb(0x00, 0x3C0);
  47.  
  48.     outb((themode->MiscOutReg | 1), 0x3C2);
  49.  
  50.     for (i=0; i<5; i++)
  51.         outw(((themode->Sequencer[i] << 8) | i), 0x3C4);
  52.  
  53.     outw((((themode->CRTC[17] & 0x7F) << 8) | 17), 0x3D4);
  54.  
  55.     for (i=0; i<25; i++)
  56.         outw(((themode->CRTC[i] << 8) | i), 0x3D4);
  57.  
  58.     for (i=0; i<9; i++)
  59.         outw(((themode->Graphics[i] << 8) | i), 0x3CE);
  60.  
  61.     for (i=0; i<21; i++) {
  62.         inb(0x3DA);
  63.         outb(i, 0x3C0);
  64.         outb(themode->Attribute[i], 0x3C0);
  65.     }
  66.  
  67.     inb(0x3DA);
  68.     outb(0x20, 0x3C0);
  69.  
  70.     return VGA_OK;
  71. }
  72.